package com.wln.kms.kms.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wln.kms.kms.entity.BargainRecordEntity;
import com.wln.kms.kms.service.BargainRecordService;
import com.wln.common.utils.PageUtils;
import com.wln.common.utils.R;



/**
 * 
 *
 * @author wulinna
 * @email 2258732595@qq.com
 * @date 2022-03-10 10:47:57
 */
@RestController
@RequestMapping("kms/bargainrecord")
public class BargainRecordController {
    @Autowired
    private BargainRecordService bargainRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bargainRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
//    @RequestMapping("/info/{recordId}")
//    public R info(@PathVariable("recordId") Long recordId){
//		BargainRecordEntity bargainRecord = bargainRecordService.getById(recordId);
//
//        return R.ok().put("bargainRecord", bargainRecord);
//    }

    @RequestMapping("/info/{activityHid}")
    public R info(@PathVariable("activityHid") Long activityHid){
        List<BargainRecordEntity> list = bargainRecordService.list(new QueryWrapper<BargainRecordEntity>().eq("activity_hid", activityHid));

        return R.ok().put("bargainRecord", list);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BargainRecordEntity bargainRecord){
		bargainRecordService.save(bargainRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BargainRecordEntity bargainRecord){
		bargainRecordService.updateById(bargainRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] recordIds){
		bargainRecordService.removeByIds(Arrays.asList(recordIds));

        return R.ok();
    }

}
